# From Greblus: https://blog.greblus.net/2014/11/18/msys2mingw-w64-cython-i-ipython-notebook/

_realname=zeromq
pkgbase=mingw-w64-${_realname}
pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=4.2.3
pkgrel=2
pkgdesc="Fast messaging system built on sockets, C and C++ bindings. aka 0MQ, ZMQ (mingw-w64)"
arch=('any')
url="http://www.zeromq.org"
license=("LGPL")
depends=("${MINGW_PACKAGE_PREFIX}-libsodium")
makedepends=("${MINGW_PACKAGE_PREFIX}-gcc")
options=('staticlibs' 'strip' '!buildflags')
source=("https://github.com/zeromq/libzmq/releases/download/v${pkgver}/${_realname}-${pkgver}.tar.gz"
        "https://raw.githubusercontent.com/zeromq/cppzmq/1fdf3d1dfe1491209b0d7c71e38b2f1e3f801ac9/zmq.hpp")
sha256sums=('8f1e2b2aade4dbfde98d82366d61baef2f62e812530160d2e6d0a5bb24e40bc0'
            '88d5978e7c7220e71aa7aa255081e7e01502d18d89f2eb9d42b96a43bb642293')

build() {
  [[ -d "${srcdir}"/build-${CARCH} ]] && rm -rf "${srcdir}"/build-${CARCH}
  mkdir -p ${srcdir}/build-${CARCH}
  cd ${srcdir}/build-${CARCH}
  
  # CXXFLAGS+=" -DZMQ_HAVE_WINDOWS_TARGET_XP" - for next version
  ../${_realname}-${pkgver}/configure \
    --prefix=${MINGW_PREFIX} \
    --build=${MINGW_CHOST} \
    --host=${MINGW_CHOST} \
    --with-libsodium \
    --enable-shared \
    --enable-static

  make
}

package() {
  mkdir -p "${pkgdir}${MINGW_PREFIX}/bin"
  mkdir -p "${pkgdir}${MINGW_PREFIX}/include"

  cd "${srcdir}/build-${CARCH}"
  make DESTDIR="${pkgdir}" install
  install -Dm644 "${srcdir}/zmq.hpp" "${pkgdir}${MINGW_PREFIX}/include/zmq.hpp"
}
